package ma.klagrida;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import org.primefaces.event.SlideEndEvent;
import org.primefaces.event.TabChangeEvent;
import org.primefaces.event.TabCloseEvent;
 
@ManagedBean
public class SliderView {

	private int number1;
	private int number2; 
	private int number3=10;
	private int number4;
	private int number5; 
	private int number6;
	private int number7;
	private int number8;
	private int number9=2000;
	private int vmprice=10;
	private int tailleprice=10;
	private int dispoprice=10;
	private int bpprice=10;
	private int stockprice=10;
	private boolean bool1;  
    private boolean bool2;
	private String disponibilite = "Start";
	private String taille = "Small";
	private String bande = "10Mbps";
	private String stockage="100Go";
		
	//   Getters & Setters
	
	public int getNumber1() {
		return number1;
	}
	public void setNumber1(int number1) {
		this.number1 = number1;
	}
	public int getNumber2() {
		return number2;
	}
	public void setNumber2(int number2) {
		this.number2 = number2;
	}
	public int getNumber3() {
		return number3;
	}
	public void setNumber3(int number3) {
		this.number3 = number3;
	}
	public int getNumber4() {
		return number4;
	}
	public void setNumber4(int number4) {
		this.number4 = number4;
	}
	public int getNumber5() {
		return number5;
	}
	public void setNumber5(int number5) {
		this.number5 = number5;
	}
	public int getNumber6() {
		return number6;
	}
	public void setNumber6(int number6) {
		this.number6 = number6;
	}
	public int getNumber7() {
		return number7;
	}
	public void setNumber7(int number7) {
		this.number7 = number7;
	}
	public int getNumber8() {
		return number8;
	}
	public void setNumber8(int number8) {
		this.number8 = number8;
	}
	public int getNumber9() {
		return number9;
	}
	public void setNumber9(int number9) {
		this.number9 = number9;
	}
	public String getDisponibilite() {
		return disponibilite;
	}
	public void setDisponibilite(String disponibilite) {
		this.disponibilite = disponibilite;
	}
	public String getTaille() {
		return taille;
	}
	public void setTaille(String taille) {
		this.taille = taille;
	}
	public String getBande() {
		return bande;
	}
	public void setBande(String bande) {
		this.bande = bande;
	}
	public String getStockage() {
		return stockage;
	}
	public void setStockage(String stockage) {
		this.stockage = stockage;
	}
	public boolean isBool1() {
		return bool1;
	}
	public void setBool1(boolean bool1) {
		this.bool1 = bool1;
	}
	public boolean isBool2() {
		return bool2;
	}
	public void setBool2(boolean bool2) {
		this.bool2 = bool2;
	}
	public int getVmprice() {
		return vmprice;
	}
	public void setVmprice(int vmprice) {
		this.vmprice = vmprice;
	}
	public int getTailleprice() {
		return tailleprice;
	}
	public void setTailleprice(int tailleprice) {
		this.tailleprice = tailleprice;
	}
	public int getDispoprice() {
		return dispoprice;
	}
	public void setDispoprice(int dispoprice) {
		this.dispoprice = dispoprice;
	}
	public int getBpprice() {
		return bpprice;
	}
	public void setBpprice(int bpprice) {
		this.bpprice = bpprice;
	}
	public int getStockprice() {
		return stockprice;
	}
	public void setStockprice(int stockprice) {
		this.stockprice = stockprice;
	}
	
	// On Slide Ends
	
	public void onSlideEnd(SlideEndEvent event) {
	 	int value = event.getValue();
	 	number3 = value;
	 	sumPrice();
	}
	
	public void onSlideEnd1(SlideEndEvent event) {
	 	int value = event.getValue();
	 	if(value == 0) {
	 		disponibilite = "Start";
	 		number2=0;
	 	 } else if(value == 50) {
		 	disponibilite = "Medium";
		 	number2=25;
		 	number9+=2000;
	 	 } else {
	 		disponibilite = "Large";
	 		number2=50;
	 		number9+=3000;
		 }
	 	sumPrice();
	}
	
	public void onSlideEnd2(SlideEndEvent event) {
	 	int value = event.getValue();
	 	if(value == 0) {
	 		taille = "Small";
	 		number2=0;
	 	 } else if(value == 50) {
		 	taille = "Large";
		 	number2=25;
	 	 } else {
	 		taille = "ExtraLarge";
	 		number2=50;
		 }
	 	sumPrice();
	}
	
	public void onSlideEnd3(SlideEndEvent event) {
	 	int value = event.getValue();
	 	if(value == 0) {
	 		bande = "10Mbps";
	 	 } else if(value == 25) {
	 		bande = "20Mbps";
	 	 } else if(value == 50) {
	 		bande = "50Mbps";
	 	} else if(value == 75) {
	 		bande = "100Mbps";
	 	} else {
	 		bande = "500Mbps";
	 	 }
	 	sumPrice();
	}
	
	public void onSlideEnd4(SlideEndEvent event) {
	 	int value = event.getValue();
	 	switch (value){
	 		case 0:  setStockage("100Go"); break;
	 		case 10: setStockage("200Go"); break;
	 		case 20: setStockage("400Go"); break;
	 		case 30: setStockage("600Go"); break;
	 		case 40: setStockage("800Go"); break;
	 		case 50: setStockage("1To"); break;
	 		case 60: setStockage("1.2Go"); break;
	 		case 70: setStockage("1.4Go"); break;
	 		case 80: setStockage("1.6Go"); break;
	 		case 90: setStockage("1.8To"); break;
	 		default: setStockage("2To"); break;
	 	}
	 	sumPrice();
	}
	
	public void sumPrice(){
		number9 = number3+vmprice+tailleprice+dispoprice+bpprice+stockprice;
	}
	
	public void onTabChange(TabChangeEvent event) {
        FacesMessage msg = new FacesMessage("Tab Changed", "Active Tab: " + event.getTab().getTitle());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
         
    public void onTabClose(TabCloseEvent event) {
        FacesMessage msg = new FacesMessage("Tab Closed", "Closed tab: " + event.getTab().getTitle());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}
